/*
 * @Author: 姚潘涛
 * @Date: 2024-10-13 11:01:35
 * @LastEditors: 姚潘涛
 * @LastEditTime: 2024-10-13 11:01:38
 * @Description:
 *
 * Copyright (c) 2024 by pandaman, All Rights Reserved.
 */
#include "xict_common/utils/registerer.h"

namespace xict_common {
    namespace utils {
        BaseClassMap& GlobalFactoryMap() {
            static BaseClassMap factory_map;
            return factory_map;
        }

        bool GetRegisteredClasses(
            const std::string& base_class_name,
            std::vector<std::string>* registered_derived_classes_names) {
            if (registered_derived_classes_names == nullptr) {
                AERROR << "registered_derived_classes_names is not available";
                return false;
            }
            BaseClassMap& map = GlobalFactoryMap();
            auto iter         = map.find(base_class_name);
            if (iter == map.end()) {
                AERROR << "class not registered:" << base_class_name;
                return false;
            }
            for (const auto& pair : iter->second) {
                registered_derived_classes_names->push_back(pair.first);
            }
            return true;
        }

    }   // namespace utils
}   // namespace xict_common
